#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,Q,op,x,v,ans;
int a[8005];
int main()
{
	freopen("sort.in","r",stdin);
	freopen("sort.out","w",stdout);
	scanf("%d%d",&n,&Q);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=0;i<Q;i++)
	{
		scanf("%d",&op);
		if(op==1)
		{
			scanf("%d%d",&x,&v);
			a[x]=v;
		}
		if(op==2)
		{
			scanf("%d",&x);
			ans=0;
			for(int j=1;j<=n;j++)
			{
				if(j<=x&&a[j]<=a[x]) ans++;
				else if(j>x&&a[j]<a[x]) ans++;
			}
			printf("%d\n",ans);
		}
	}
	fclose(stdin);
	fclose(stdout);
}
